Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Securty Group name must be unique #53714

Merged

Conversation

FengyunPan
Copy link

@FengyunPan FengyunPan commented Oct 11, 2017

Currently the service's name is not unique, and the Securty Group
name is not unique too. openstack cloud provider will delete the
Securty Group of other loadbalancer service when do a deletion.

OpenStack cloud provider get the ID of Securty Group by name, so the Securty Group name must be unique.
https://github.com/kubernetes/kubernetes/blob/master/pkg/cloudprovider/providers/openstack/openstack_loadbalancer.go#L1262

Release note:

NONE

Currently the service's name is not unique, and the Securty Group
name is not unique too. openstack cloud provider will delete the
Securty Group of other loadbalancer service when do a deletion.
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 11, 2017
@FengyunPan
Copy link
Author

/assign @dims

@FengyunPan FengyunPan changed the title The Securty Group name should be unique The Securty Group name must be unique Oct 11, 2017
@FengyunPan
Copy link
Author

/test pull-kubernetes-kubemark-e2e-gce

@dims
Copy link
Member

dims commented Oct 11, 2017

/approve no-issue
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 11, 2017
@dims
Copy link
Member

dims commented Oct 11, 2017

/sig openstack

@k8s-ci-robot k8s-ci-robot added the area/provider/openstack Issues or PRs related to openstack provider label Oct 11, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dims, FengyunPan

Associated issue requirement bypassed by: dims

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 11, 2017
@FengyunPan
Copy link
Author

/test pull-kubernetes-e2e-gce-gpu

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit cea1af3 into kubernetes:master Oct 12, 2017
Copy link
Member

@anguslees anguslees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well spotted!

How do we make this work for upgrades? I think we need to look up the old name during update/delete (not create) if the new name doesn't exist - at least for a release (add a dated deprecation comment so we remember when it's safe to remove). It's probably going to be easiest if we just forcibly update the name when we find the old name (assuming we can do that?), to ensure the transition happens within our deprecation window.

@@ -372,7 +372,7 @@ func popMember(members []v2pools.Member, addr string, port int) []v2pools.Member
}

func getSecurityGroupName(clusterName string, service *v1.Service) string {
return fmt.Sprintf("lb-sg-%s-%v", clusterName, service.Name)
return fmt.Sprintf("lb-sg-%s-%s-%s", clusterName, service.Namespace, service.Name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another alternative would be to use the service UID, which is also unique over time (but less readable).

If I delete a service and then quickly create a new one with the same namespace/name - what do we want to have happen to the securityGroup?

I think we want the securityGroup to not overlap in this case (so the old one can be cleaned up in parallel with the new one being created, without conflicts).
... So I think this means that this function should return

fmt.Sprintf("lb-sg-%s", service.UID)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I delete a service and then quickly create a new one with the same namespace/name - what do we want to have happen to the securityGroup?

That make sense. The service.UID is less readable.
How about "fmt.Sprintf("lb-sg-%s-%s-%s", clusterName, service.Namespace, service.Name, service.UID)"?

Copy link
Member

@anguslees anguslees Oct 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's now very long - is there any length limit that we need to worry about here? A quick look at the code seems to imply that the name is limited to 255 chars, so I think we're ok on length.

Another (better?) option would be to use the securityGroup "description" field (also 255 chars) rather than trying to mash all our user-friendly text in the name field. That way we can have spaces, etc and change the specific text over time without worrying about wider impact.

Personally, I think the user is going to have a pretty good idea of which cluster a securityGroup is related to, and will be able to quickly find the relevant Service based on context, ports referred to, etc without needing any additional help. I agree that the UID is less readable though - so I agree that either your long-name version or the above name+description version is better than my original short-name-only version.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, I will check the size of its name.

FengyunPan pushed a commit to FengyunPan/kubernetes that referenced this pull request Oct 12, 2017
FengyunPan pushed a commit to FengyunPan/kubernetes that referenced this pull request Oct 12, 2017
FengyunPan pushed a commit to FengyunPan/kubernetes that referenced this pull request Oct 12, 2017
FengyunPan pushed a commit to FengyunPan/kubernetes that referenced this pull request Oct 12, 2017
FengyunPan pushed a commit to FengyunPan/kubernetes that referenced this pull request Nov 21, 2017
k8s-github-robot pushed a commit that referenced this pull request Nov 29, 2017
Automatic merge from submit-queue (batch tested with PRs 56520, 53764). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Add service.UID into security group name

Related to: #53714 

**Release note**:
```release-note
NONE
```
dims pushed a commit to dims/kubernetes that referenced this pull request Feb 8, 2018
…Name

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

The Securty Group name must be unique

Currently the service's name is not unique, and the Securty Group
name is not unique too. openstack cloud provider will delete the
Securty Group of other loadbalancer service when do a deletion.

OpenStack cloud provider get the ID of Securty Group by name, so the Securty Group name must be unique.
https://github.com/kubernetes/kubernetes/blob/master/pkg/cloudprovider/providers/openstack/openstack_loadbalancer.go#L1262

**Release note**:
```release-note
NONE
```
dims pushed a commit to dims/kubernetes that referenced this pull request Feb 8, 2018
dims pushed a commit to dims/kubernetes that referenced this pull request Feb 8, 2018
Automatic merge from submit-queue (batch tested with PRs 56520, 53764). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Add service.UID into security group name

Related to: kubernetes#53714 

**Release note**:
```release-note
NONE
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/provider/openstack Issues or PRs related to openstack provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants